function lnp = dirichletln(x, a, x_type)

const_norm = gammaln(sum(a)) - sum(gammaln(a));
if nargin > 2 
    if x_type == 'log'
        lnp = sum((a-1).*x) + const_norm;
    else
        error('incorrect x type');
    end
else
    lnp = sum((a-1).*log(x)) + const_norm;
end 
